$app.open();
let data = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15"];
$ui.render({
  props: { title: "价格查询" },
  views: [
    {
      type: "label",
      props: { id: "lblFind", text: "查找：", align: $align.left },
      layout: function (make, view) {
        make.top.equalTo(13);
        make.left.inset(10);
        make.size.equalTo($size(50, 25));
      }
    },
    {
      type: "input",
      props: { id: "txtPattern", type: $kbType.number, placeholder: "" },
      layout: function (make, view) {
        make.top.equalTo(10);
        make.left.equalTo($("lblFind").right).offset(1);
        make.size.equalTo($size(230, 30));
      },
      events: {
        ready: function (sender) {
          sender.text = $clipboard.text ? $clipboard.text : "";
          sender.focus();
        },
        changed: function (sender) {},
        returned: function (sender) {
          sender.blur();
        }
      }
    },
    {
      type: "button",
      props: { id: "taobaoButton", title: "查询" },
      layout: function (make, view) {
        make.top.equalTo(10);
        make.left.equalTo($("txtPattern").right).offset(20);
        make.size.equalTo($size(80, 30));
      },
      events: {
        tapped: function (sender) {
          $clipboard.text = $("txtPattern").text;
          $app.openURL(
            "taobao://s.taobao.com/?q=" + encodeURI($("txtPattern").text)
          );
        }
      }
    },
    {
      type: "list",
      props: { data },
      layout:  function (make, view) {
            make.top.equalTo($("lblFind").bottom).offset(10);
            // make.left.equalTo($("txtPattern").right).offset(20);
            // make.width.equalTo($layout.fill.width)
            // make.height.equalTo($layout.fill.height)
            make.size.equalTo($size(777, 1130));
          },
      events: {
        didReachBottom: function(sender) {
          $ui.toast("fetching...")
          $delay(0.1, () => {
            sender.endFetchingMore()
            data = data.concat(data.map(item => {
              return (parseInt(item) + 15).toString()
            }))
            $("list").data = data
          })
        }
      }
    }
  ]
});
